package ioperation;

import Book.Book;
import Book.Booklist;

import java.util.Scanner;

/**
 * Created with Interllij IDEA.
 * Descriptiption:
 * User: 王澄慧
 * Date: 2022-04-16
 * Time: 20:20
 */
public class Findiperation implements IPeration {
    @Override
    public void work(Booklist booklist) {
        System.out.println("查找图书");
        System.out.println("请输入你想要查找的书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int currentSize = booklist.getUserSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = booklist.getpos(i);
            if (book.getName().equals(name)) {
                System.out.println("找到了这本书，信息如下：");
                booklist.setBooks(i,book);
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有这本书！");
    }
}
